package com.dongdongshop.core;

public class Result {
    private Integer code;
    private String message;

    public Result(Integer code, String message) {
        this.code = code;
        this.message = message;
    }

    private Object data;

    public Result() {
    }

    public Result(Integer code, String message, Object data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }

//    // 方式一不带数据的公共返回结果成功
//    public static Result success(){
//        return new Result(ResponseMessage.SECCESSCODE,ResponseMessage.SUCCESS);
//    }
//
//    public static Result fail(){
//        return new Result(ResponseMessage.FAILECODE,ResponseMessage.FAILE);
//    }
    //方式2
    public static Result response(ResultEnum resultEnum){
        return  new Result(resultEnum.getCode(),resultEnum.getMessage());
    }

    public Integer getCode() {
        return code;
    }

    public void setCode(Integer code) {
        this.code = code;
    }

    public String getMessage() {
        return message;
    }

    public void setMessage(String message) {
        this.message = message;
    }

    public Object getData() {
        return data;
    }

    public Result setData(Object data) {
        this.data = data;
        return this;
    }
}
